import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.useGlobalPipes(new ValidationPipe({ transform: true })); // 全局验证管道，将数据转换为DTO对象
  app.useStaticAssets(join(__dirname, '..', 'uploads'), { prefix: '/uploads' }); // 设置静态资源目录
  app.setGlobalPrefix('api'); // 设置全局前缀
  app.enableCors(); // 允许跨域
  await app.listen(4444);
}
bootstrap();
